#pragma once

#include "spellcheck.h"
#include "trie.h"
#include "BigramCollection.h"

#include <memory>
#include <utility>

namespace NSpellCheck {

class DefaultSpellChecker: public NSpellCheck::ISpellChecker {
public:
    DefaultSpellChecker(Trie<int>* unigrams, BigramCollection* bigrams);
    virtual ~DefaultSpellChecker();
    virtual void process(const Phrase& phrase, std::vector<Variation>* suggestions) const;
private:
    void findWordVariations(const std::string& word, std::vector<Variation>* variations) const;
    void findSplitVariations(std::string word, std::vector<Variation>* variations) const;
    double languageModel(const Phrase& phrase) const;
    std::pair<size_t, int> findSplitIndex(const std::string& word) const;
    bool findMergeVariations(const Phrase& phrase, std::vector<Variation>* variations) const;
private:
    std::auto_ptr<Trie<int> > unigrams;
    std::auto_ptr<BigramCollection> bigrams;

};

} //ns
